package com.poker.controller;

import com.poker.entity.UserHonor;
import com.poker.service.UserHonorService;
import com.poker.util.Misc;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * @ClassName UserHonorController
 * @Description TODO
 * @Author duyuanyuan
 * @Date 2019/3/13 13:34
 * @Version 1.0
 **/
@Controller
@RequestMapping("/userHonor")
public class UserHonorController extends BaseController{

    @Resource
    private UserHonorService userHonorService;
    /*
     * 功能描述:查询用户荣誉返回颁布证书页面
     * @param:  * @param model
     * @param userid
     * @param activityid
     * @return: java.lang.String
     * @auther: duyuanyuan
     * @date: 2019/3/18 10:57
     */
    @RequestMapping("/edit")
    public String edit(Model model, String userid,String activityid) {
        UserHonor  honor = userHonorService.getByUseridAndActivityId(userid,activityid);
        model.addAttribute("userHonor", honor);
        return managerPage("userhonor/edit");
    }
   /*
    * 功能描述:提交为用户颁布的证书
    * @param:  * @param userHonor
    * @return: java.lang.String
    * @auther: duyuanyuan
    * @date: 2019/3/18 11:02
    */
    @ResponseBody
    @RequestMapping("/doEdit")
    public String doEdit(UserHonor userHonor) {
        if (Misc.isEmpty(userHonor) || Misc.isEmpty(userHonor.getId())) toJson(false, "编辑信息为空", null);
        userHonorService.update(userHonor);
        return toJson(true, "success", null);
    }
}
